#include "../logs/gjclog.h"
#include "unistd.h"

void test_log(const std::string &name)
{
    INFO("%s", "开始测试");
    gjclog::Logger::ptr logger = gjclog::LoggerManager::getInstance().getLogger(name);
    logger->debug("%s", "测试日志");
    logger->info("%s", "测试日志");
    logger->warn("%s", "测试日志");
    logger->error("%s", "测试日志");
    logger->fatal("%s", "测试日志");
    INFO("%s", "结束测试");
}

int main()
{
    std::unique_ptr<gjclog::LoggerBuilder> builder(new gjclog::GlobalLoggerBuilder());
    builder->bulidLoggerName("sync_logger");
    builder->buildLoggerLevel(gjclog::LogLevel::value::DEBUG);
    builder->buildFormatter("[%c][%f:%l][%p]%m%n");
    builder->buildLoggerType(gjclog::LoggerType::LOGGER_SYNC);  // 同步日志
    builder->buildSink<gjclog::FileSink>("./logfile/sync.log");
    builder->buildSink<gjclog::StdoutSink>();
    builder->buildSink<gjclog::RollBySizeSink>("./logfile/roll-sync-by-size", 1024 * 1024);
    builder->build();
    test_log("sync_logger");
    return 0;
}